/**
 * Copyright (c) 2011-2015 1lifes.com
 * HSJ java-handlersocket
 * Id: HSJManager.java
 */
package com.elifes.hsj;

import java.sql.ResultSet;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Future;

import com.elifes.hsj.client.HSJClient;
import com.elifes.hsj.exception.HSJException;
import com.elifes.hsj.model.CompareOperator;
import com.elifes.hsj.model.Filter;
import com.elifes.hsj.model.INFilter;
import com.elifes.hsj.model.Modify;
import com.elifes.hsj.model.TableConfig;

/**
 * 描述：hs对外提供服务的管理类接口
 * 
 * @author yangqiang
 * @param <T>
 * @createtime 2011-11-12下午12:17:28
 * 
 */
public interface HSJManager {
	/**
	 * 
	 * 描述：初始化本次操作信息（数据表信息）
	 * @param dbLookupStrategy 获取的连接信息的策略类
	 * @param lookupKeyMap 分库分表字段
	 * @return 获取连接的indexid
	 */
	public String init(IDBLookupStrategy dbLookupStrategy, Map<String, Object> lookupKeyMap) throws HSJException;
	
	/**
	 * 
	 * 描述：初始化本次操作信息（数据表信息）
	 * @param dbLookupStrategy 获取的连接信息的策略类
	 * @param lookupKeyMap 分库分表字段
	 * @param isReOpen 重新openindex，当操作的表字段需要变化时 设置为true
	 * @return 获取连接的indexid
	 */
	public String init(IDBLookupStrategy dbLookupStrategy, Map<String, Object> lookupKeyMap, boolean isReOpen) throws HSJException;
	
	/** blocking start */
	/**
	 * 
	 * 描述：插入数据
	 * 
	 * @param indexId
	 * @param values
	 * @return true 插入成功
	 * @throws HSJException
	 */
	public boolean insert(String indexId, List<String> values) throws HSJException;

	/**
	 * 
	 * 描述：查询数据
	 * @param <T>
	 * 
	 * @param indexId
	 * @param operator
	 * @param filterValues
	 * @param limit
	 * @param offset
	 * @param in
	 * @param filters
	 * @return 查询的结果集
	 * @throws HSJException
	 */
	public Object find(String indexId, CompareOperator operator,
			List<String> filterValues, int limit, int offset,
			INFilter in, List<Filter> filters, Class doClass, List<String> properties) throws HSJException;
	
	public Object modify(String indexId, CompareOperator operator,
			List<String> filterValues, int limit, int offset,
			INFilter in, List<Filter> filters, Class doClass, List<String> properties, Modify mod) throws HSJException;
	/** blocking end */
	
	
	/** non-blocking start */
	/**
	 * 
	 * 描述：插入数据
	 * 
	 * @param indexId
	 * @param values
	 * @return true 插入成功
	 * @throws HSJException
	 */
	public Future<Boolean> asynInsert(String indexId, List<String> values) throws HSJException;

	/**
	 * 
	 * 描述：查询数据
	 * @param <T>
	 * 
	 * @param indexId
	 * @param operator
	 * @param filterValues
	 * @param limit
	 * @param offset
	 * @param in
	 * @param filters
	 * @return 查询的结果集
	 * @throws HSJException
	 */
	public Future<Object> asynFind(String indexId, CompareOperator operator,
			List<String> filterValues, int limit, int offset,
			INFilter in, List<Filter> filters, Class doClass, List<String> properties) throws HSJException;
	
	public Future<Object> asynModify(String indexId, CompareOperator operator,
			List<String> filterValues, int limit, int offset, INFilter in,
			List<Filter> filters, Class doClass, List<String> properties,
			Modify mod) throws HSJException;
	/** non-blocking end */

	public HSJClient getClient();


//	public ResultSet find(CompareOperator operator, String[] filterValues,
//			int limit, int offset, String[] filterColumnNames);
	
	//public void insert(List<String> values);
	
	//public void auth(String indexId, String authType, String authKey) throws HSJException;
	
	/**
	 * 
	 * 描述：
	 * @param tableConfig
	 * @return
	 */
	//public String openIndex(TableConfig tableConfig) throws HSJException;
	

	
//	public String openIndex(String dbName, String tblName, String indexName,
//			List<String> columnNames) throws HSJException;
}
